#pragma once

#include <atomic>
#include <memory>
#include <mutex>
#include <thread>

#include <include/core/SkTypeface.h>
#include <SDL2/SDL.h>

class SkCanvas;

class Test {
    SDL_Window *window_ = nullptr;
    SDL_Renderer *renderer_ = nullptr;
    SDL_Surface *surface_ = nullptr;
    SDL_Texture *texture_ = nullptr;
    SDL_Rect rect_ = {};

    std::unique_ptr<std::thread> uiThread_ = nullptr;
    std::atomic<bool> uiThreadRunning_ = true;

    std::mutex propsMutex_;
    std::atomic<int> x_ = 0;
    std::atomic<int> y_ = 0;
    std::atomic<bool> left_ = false;
    std::atomic<double> scale_ = 1;

    sk_sp<SkTypeface> typeface_ = nullptr;

public:
    Test(int winWidth = 800, int winHeight = 640);
    ~Test();

    void Run();
    void UIThreadTest();
    virtual void Draw(SkCanvas &canvas);
    virtual void DrawAfter(SkCanvas &canvas);
};
